package org.dolphin.action;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.InterceptorRefs;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.dolphin.base.json.StatusBean;
import org.dolphin.service.base.UserProfileHelper;
import com.opensymphony.xwork2.ActionSupport;

@ParentPackage("custom-default")
@Namespace(value = "/")
@InterceptorRefs(value = {@InterceptorRef(value = "customStack")})
public class WelcomeAction extends ActionSupport {
  private static final long serialVersionUID = -5249588871935347537L;
  private StatusBean status;

  @Action(value = "getActiveUser", results = @Result(name = "success", params = {"root",
      "status.attrs"}, type = "json"))
  public String getActiveUser() {
    String username = UserProfileHelper.getUserFullname();
    status = new StatusBean();
    status.addAttr("username", username);
    return SUCCESS;
  }

  public StatusBean getStatus() {
    return status;
  }

  public void setStatus(StatusBean status) {
    this.status = status;
  }

  @Action(value = "welcome", results = @Result(name = "success", location = "home/welcome.jsp"))
  public String welcome() {
    return SUCCESS;
  }
}
